package com.hns.can.service.web;

import com.hns.can.common.web.BaseController;
import com.hns.can.service.entity.BaseDrvCommentEntity;
import com.hns.can.service.service.DriverCommentService;
import com.hns.can.service.vo.DriverCommentVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 评语设置Controller
 * @author:zhangzq
 * @email:
 * @version Revision 2.0.0
 */
@Controller
@RequestMapping("/driverComment")
public class DriverCommentController extends BaseController {

    @Autowired
    private DriverCommentService driverCommentService;

    /**
     * @param corpId
     * @param organId
     * @param qcodeValue
     * @param qcommentTypeCodes
     * @throws Exception
     * @author:zhangzq
     * @email:
     * @功能说明：查询评语设置信息(该机构下没有相应配置就取默认的)
     */
    @RequestMapping("/searchDriverCommentInfo")
    @ResponseBody
    public Object searchDriverCommentInfo(String corpId, String organId, String qcodeValue, String[] qcommentTypeCodes) throws Exception {
        Map<String, Object> paraMap = new HashMap<String, Object>();
        paraMap.put("organId", organId);
        paraMap.put("corpId", corpId);
        paraMap.put("qcommentTypeCodes", qcommentTypeCodes);
        paraMap.put("qcodeValue", qcodeValue);
        List<BaseDrvCommentEntity> list = driverCommentService.searchDrvCommentInfo(paraMap);
        return this.getReturnResult(list);
    }

    /**
     * @param data
     * @throws Exception
     * @author:zhangzq
     * @email:
     * @功能说明：更新或新增评语设置信息
     */
    @RequestMapping("/uptDriverCommentInfo")
    @ResponseBody
    public Object uptDriverCommentInfo(DriverCommentVo data) throws Exception {
        driverCommentService.uptDrvCommentInfo(data);
        return this.getReturnMsg("您成功修改该机构的评语设置信息。");
    }
}
